package com.walle.concurrenttest.pattern.workthread;

import java.util.Random;

/**
 * @author zhangjiapeng
 * @Package com.walle.concurrenttest.pattern.workthread
 * @Description: ${todo}
 * @date 2019/2/22 10:36
 */
public class Request {

    private String name;
    private int number;
    private Random random = new Random();


    public Request(String name, int number) {
        this.name = name;
        this.number = number;
    }

    public void execute(){
        String threadName = Thread.currentThread().getName();
        System.out.println(threadName + " execute " + this);
        try {
            Thread.sleep(random.nextInt(1000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


    @Override
    public String toString() {
        return String.format("Request No.%d from %s",number,name) ;
    }
}
